package com.dotflat.fin.domain;

import com.dotflat.rest.domain.AreableObjectBase;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;

/**用户钱包流水信息*/
@Data
@Entity
@Table(name="fin_wallet_flow")
@EqualsAndHashCode(callSuper = true)
public class WalletFlow extends AreableObjectBase {

    @Column(length = 32)
    private String walletId;

    @Column(columnDefinition = "INT COMMENT '类型：0.无变化 1. 进账 2. 出账'")
    private Integer type;

    @Column(columnDefinition = "INT COMMENT '来源类型：0. 无变化 1. 现金动账 2. 项目操作 3. 系统操作'")
    private Integer sourceType;

    @Column(columnDefinition = "varchar(2048) COMMENT '内容'")
    private String commentInfo;

    @Column(columnDefinition = "INT COMMENT '金额'")
    private Long money;


    public static WalletFlow of(String walletId, String createdBy, Integer sourceType, Integer type, Long money, String commentInfo){
        WalletFlow walletFlow = new WalletFlow();

        walletFlow.setWalletId(walletId);
        walletFlow.setCreated(new Date());
        walletFlow.setCreatedBy(createdBy);

        walletFlow.setSourceType(sourceType);
        walletFlow.setType(type);

        walletFlow.setMoney(money);
        walletFlow.setCommentInfo(commentInfo);

        return walletFlow;
    }
}
